package cn.howxu.yichen_ovo.common.item;

import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * @description: TODO
 * @author: HowXu
 * @date: 2025/10/1 10:00
 */
public class WYG extends Item {
    public WYG() {
        super(new Properties().stacksTo(32).rarity(Rarity.EPIC));
    }

    @Override
    public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltipComponents, TooltipFlag pIsAdvanced) {
        super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced);
        pTooltipComponents.add(Component.translatable("tip.yichenovo.wuyige").withStyle(ChatFormatting.GOLD));
    }

    @Override
    public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) {
        var stack = pPlayer.getItemInHand(pUsedHand);
        // 客户端看女巫跳舞
        if (pLevel.isClientSide()){
            //pPlayer.sendSystemMessage(Component.translatable("sadsadasdasdasdas"));
            displayDance(pPlayer);
        }
        // 非客户端 物品减少
        stack.shrink(1);
        return InteractionResultHolder.sidedSuccess(stack,pLevel.isClientSide());
    }
    
    // Gui解码视频和音频
    @OnlyIn(Dist.CLIENT)
    private void displayDance(Player pPlayer){
        pPlayer.sendSystemMessage(Component.translatable("tip.yichenovo.no_dance1").withStyle(ChatFormatting.RED));
        pPlayer.sendSystemMessage(Component.translatable("tip.yichenovo.no_dance2").withStyle(ChatFormatting.RED));
    }
}
